﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Odbc;

namespace Lyon.Data.ORM.DataBases
{
    /// <summary>
    /// Odbc数据库
    /// </summary>
    public class OdbcDataBase: AbstractDataBase, IDataBase
    {
        string _ConnectionString;
        string _ParameterNamePrefix;

        /// <summary>
        /// 创建一个打开的数据库连接。
        /// </summary>
        protected override IDbConnection CreateConnection()
        {
            OdbcConnection conn = new OdbcConnection(_ConnectionString);
            return conn;
        }
        /// <summary>
        /// 参数名前缀。
        /// </summary>
        protected override string ParameterNamePrefix
        {
            get { return _ParameterNamePrefix; }
        }
        /// <summary>
        /// 初始化。
        /// </summary>
        /// <param name="connectionString">数据库连接。</param>
        public OdbcDataBase(string connectionString)
            : this(connectionString, "?")
        {
        }
        /// <summary>
        /// 初始化。
        /// </summary>
        /// <param name="connectionString">数据库连接。</param>
        /// <param name="parameterNamePrefix">参数名前缀。</param>
        public OdbcDataBase(string connectionString, string parameterNamePrefix)
        {
            Guard.ArgumentNotNullOrEmptyString(connectionString, "connectionString");
            _ConnectionString = connectionString;
            _ParameterNamePrefix = parameterNamePrefix;
        }

        
    }
}
